package com.frxuexi.park2210.notice

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.SPUtils
import com.blankj.utilcode.util.ToastUtils
import com.frxuexi.lib_base.mvvm.BaseActivity
import com.frxuexi.lib_base.net.Const
import com.frxuexi.park2210.R
import com.frxuexi.park2210.databinding.ActivityNoticeAddBinding
import dagger.hilt.android.AndroidEntryPoint

@Route(path = "/app/NoticeAddActivity")
@AndroidEntryPoint
class NoticeAddActivity : BaseActivity<ActivityNoticeAddBinding,NoticeViewModel>() {
    override fun initData() {
        vm.addnoticeSuc.observe(this){
            ToastUtils.showLong("添加成功")
            finish()
        }
    }

    override fun initView() {
        binding.headerNotice.apply {
            headerBack.setOnClickListener {
                finish()
            }
            headerTitle.setText("添加公告")
        }

        binding.btnAddnotice.setOnClickListener {
            val map = mutableMapOf<String, Any>()
            map["noticeTitle"]=binding.etNoticeTitle.text.toString()
            map["noticeValue"]=binding.etNoticeValue.text.toString()
            map["userId"]=SPUtils.getInstance().getInt(Const.UID)
            vm.addNotice(map)
        }
    }

}